package leetcode;

public class Day16 {
    public static void merge(int[] nums1, int m, int[] nums2, int n) {
    int min=Math.min(m,n);
    int[] ret=new int[m+n];
    int i=0;
    int j=0;
    int r=0;
    while (i<min&&j<min){
        if (nums1[i]<=nums2[j]){
            ret[r]=nums1[i];
            r++;
            i++;
        }else {
           ret[r]=nums2[j];
           r++;
           j++;
        }
    }
    if(min==m){
        for (int a=m;a<n-1;a++){
            ret[a]=nums2[a];
        }
    }else {
        for (int a=n;a<m-1;a++){
            ret[a]=nums1[a];
        }
    }
    }

    public static void main(String[] args) {
        int[] arr1={1,2,3};
        int[] arr2={2,5,6};
        merge(arr1,3,arr2,3);
    }
}
